package feed

import (
	"context"
)

func (*Service) PreLoadFeed(c context.Context, userId int) error {
	redisKey := genFollowVideoFeedListKey(userId)
	var err error
	exists, err := isFollowVideoFeedKeyExists(c, redisKey)
	if err != nil {
		return err
	}
	//不存在从db拉取数据
	if !exists {
		feedRelations, err := getFollowVideoFeedFromDb(userId)
		if err != nil {
			return err
		}
		//按照score存入redis中
		err = setFollowVideoFeed(c, redisKey, feedRelations)
		if err != nil {
			return err
		}
	}
	return err
}
